home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech's Sprocket™ / SprocketGX / Interfaces / Window.h < prev   
Encoding:
C/C++ Source or Header  |  1994-10-17  |  4.0 KB  |  155 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        Window.h
  3.  
  4.     Contains:    Definition of TWindow, a base class which provides a
  5.                 framework for building way-cool windows which even John
  6.                 Sullivan would be happy with. Floating windows and “smart
  7.                 zooming” algorithms are based on code samples provided by
  8.                 Dean Yu.
  9.                 
  10.     Written by: Dave Falkenburg, Dean Yu
  11.  
  12.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  13.  
  14.     Change History (most recent first):
  15.      
  16.  */
  17.  
  18. #ifndef        _WINDOW_
  19. #define        _WINDOW_
  20.  
  21. #ifndef        __TYPES__
  22. #include    <Types.h>
  23. #endif
  24.  
  25. #ifndef        __WINDOWS__
  26. #include    <Windows.h>
  27. #endif
  28.  
  29. #ifndef        __EVENTS__
  30. #include    <Events.h>
  31. #endif
  32.  
  33. #ifndef        __DRAG__
  34. #include    <Drag.h>
  35. #endif
  36.  
  37. #ifndef  _MENUBAR_
  38. #include    "StandardMenus.h"
  39. #endif
  40.  
  41. #ifndef        __CUTILITIES__
  42.     #include  "CUtilities.h"
  43. #endif
  44.  
  45. typedef    short    WindowTemplateID;
  46.  
  47.  
  48. class    TWindow
  49. {
  50. public:
  51.     enum WindowType
  52.     {
  53.         kNormalWindow = 0,
  54.         kFloatingWindow,
  55.         kModalWindow
  56.     };
  57.  
  58.                         TWindow();
  59.     virtual                ~TWindow();
  60.  
  61.     //    Event routing methods
  62.  
  63.     virtual    Boolean        EventFilter(EventRecord * theEvent);    
  64.  
  65.     //    Methods you shouldn’t need to override, but might need to
  66.  
  67.     virtual void        CreateWindow(WindowType typeOfWindowToCreate = kNormalWindow);
  68.     virtual    void        Select(void);
  69.     virtual    void        Drag(Point startPoint);
  70.     virtual void        Nudge(short horizontalDistance, short verticalDistance);
  71.     virtual void        Grow(Point startPoint);
  72.     virtual void        Zoom(short zoomState);
  73.  
  74.     virtual    void        ShowHide(Boolean showFlag);
  75.  
  76.     //    Methods which MUST be overridden:
  77.  
  78.     virtual WindowPtr    MakeNewWindow(WindowPtr behindWindow)    = 0;
  79.     
  80.  
  81.     //    Methods which probably should be overridden
  82.  
  83.     virtual    void        AdjustCursor(EventRecord * anEvent);
  84.     virtual void        Idle(EventRecord * anEvent);
  85.     virtual void        Activate(Boolean activating);
  86.     virtual void        Draw(void);
  87.     virtual void        SetupMenus(void);
  88.     virtual void        Click(EventRecord * anEvent);
  89.     virtual    void        KeyDown(EventRecord * anEvent);
  90.  
  91.     virtual void        GetPerfectWindowSize(Rect * perfectSize);
  92.     virtual    void        GetWindowSizeLimits(Rect * limits);
  93.     virtual void        AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
  94.  
  95.     virtual void        HandleMenuCommand(short theMenuID, short theMenuItem);
  96.     //    Window property accessor methods…
  97.     //        …watch for new ones when we add scripting support    
  98.     
  99.     virtual    Boolean        IsVisible(void);
  100.     
  101.     virtual    Boolean        CanClose(void);        
  102.     virtual    Boolean        Close(void);
  103.     virtual    Boolean        DeleteAfterClose(void);
  104.     
  105.     virtual    void        DoEditMenu(short item);
  106.  
  107.     //    Methods for use with the Drag Manager
  108.     
  109.     virtual    OSErr        HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
  110.  
  111.     virtual    OSErr        DragEnterWindow(DragReference theDrag);
  112.     virtual    OSErr        DragInWindow(DragReference theDrag);
  113.     virtual    OSErr        DragLeaveWindow(DragReference theDrag);
  114.  
  115.     virtual    OSErr        HandleDrop(DragReference theDragRef);
  116.  
  117. protected:
  118.     virtual  void         PageSetupDlg(Boolean theCustomFlag);
  119.     virtual  void         PrintDlg(Boolean theDialogFlag);
  120.     WindowPtr            fWindow;
  121.     WindowType            fWindowType;
  122.     Boolean                fIsVisible;
  123. };
  124.  
  125.  
  126. //    Utility Functions:
  127. #ifdef __cplusplus
  128.     extern "C" {
  129. #endif
  130.  
  131. //    Don’t you just wish you didn’t have to do this?
  132. pascal WindowPtr    GetNewColorOrBlackAndWhiteWindow(short windowID, void *wStorage, WindowPtr behind);
  133. pascal WindowPtr    NewColorOrBlackAndWhiteWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon);
  134.  
  135. TWindow *            GetWindowObject(WindowPtr aWindow);
  136.  
  137. WindowPtr            FrontModalWindow(void);
  138. WindowPtr            LastModalWindow(void);
  139. WindowPtr            FrontFloatingWindow(void);
  140. WindowPtr            LastFloatingWindow(void);
  141. WindowPtr            FrontNonFloatingWindow(void);
  142.  
  143. void                HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
  144. void                SuspendResumeWindows(Boolean resuming);
  145. void                HiliteWindowsForModalDialog(Boolean hiliting);
  146.  
  147. pascal OSErr        CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow, void *handlerRefCon, DragReference theDragRef);
  148. pascal OSErr        CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon, DragReference theDragRef);
  149.  
  150. #ifdef __cplusplus
  151.     }
  152. #endif
  153.  
  154. #endif
  155.